package com.zhongkun.datahome.service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhongkun.datahome.service.domain.MiniProgramDataSetting;
import com.zhongkun.datahome.service.res.system.MiniProgramDataSettingVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author: MinKun
 * @Date: Created in 2025/5/7
 * @Description:
 */
public interface MiniProgramDataSettingMapper extends BaseMapper<MiniProgramDataSetting> {

    @Select("select * from mini_program_data_setting where del_flag = 0 order by  parent_id asc, level asc ,sort asc")
    List<MiniProgramDataSettingVo> queryAllList();

    @Select("select * from mini_program_data_setting where level = #{level} and del_flag = 0 order by  parent_id asc, level asc ,sort asc")
    List<MiniProgramDataSettingVo> queryListByLevel(@Param("level") Integer level);

    @Update("update mini_program_data_setting set del_flag = 1 where id = #{id}")
    int deleteById(@Param("id") Long id);

    @Select("select name from mini_program_data_setting where id = #{id}")
    String queryNameById(@Param("id") Long id);

    @Select("select count(*) from mini_program_data_setting where parent_id = #{parentId} and del_flag = 0")
    int queryCountByParentId(Long parentId);
}
